<?php echo $this->render('catalog/category/_tab.phtml'); ?>
<?php
if(!function_exists('_categoryTreeList')) {
	function _categoryTreeList($tree, $ps = array(), $rid = '', $level = 0) {
		$str = "";
		foreach((array) $tree AS $row) {
			$str .= '<ul class="citem';
			if($level > 0) $str .= ' sub';
			$str .= '">';
			$str .= '<li>';
			if($rid == $row['id'] || in_array($row['parent'], $ps)) {
				if(!empty($row['children'])) {
					foreach((array) $row['children'] As $c) {
						$ps[] = $c['id'];
					}
				}
				if($rid == $row['id']) {
					$str .= '<b class="red">' . $row['name'] . '</b>';
				} else {
					$str .= '<strong>' . $row['name'] . '</strong>';
				}
				$str .= '<em>[' . $row['id'] . ']</em>';
			} else {
				$str .= '<input type="radio" name="to" id="to-' . $row['id'] . '" value="' . $row['id'] . '" />';
				$str .= '<label class="for-checkbox" for="to-' . $row['id'] . '">' . $row['name'] . '<em>[' . $row['id'] . ']</em></label>';
			}
			$str .= '</li>';
			if(!empty($row['children'])) {
				$str .= _categoryTreeList($row['children'], $ps, $rid, ($level + 1));
			}
			$str .= '</ul>';
		}
		return $str;
	}
}
?>
<form action="" method="post">
<?php echo $this->form()->hidden('referer', $this->referer) . "\n";?>
<div class="body">
	<table class="search">
		<tr>
			<th><?php echo $this->language->load('Move Category');?> [<em class="red"><?php echo $this->row->getName();?>(# <?php echo $this->row->getId();?>)</em>] <?php echo $this->language->load('To');?>:</th>
		</tr>
		<tr>
			<td><?php echo _categoryTreeList(catalog_category::allCategoryToTreeAsArray(), array($this->row->getId()), $this->row->getId());?></td>
		</tr>
		<tr>
			<td><button type="submit" name="submit" id="submit" value="submit"><?php echo $this->language->load('Move');?> »</button><button type="submit" name="top" id="top" value="1"><?php echo $this->language->load('Move To Top');?> »</button></td>
		</tr>
	</table>
</div>
</form>
